import { Table } from 'antd';
import React, {useEffect, useState} from 'react';
import {SubjectEvaluation} from "@/services/Province/Dashboard";

const App = () => {
  let [reload] = useState(false)
  let [data, setData] = useState([])
  let [loading, setLoading] = useState(true)
  const columns = [
    {
      title: '院校名称',
      dataIndex: 'school',
      key: 'school',
      render: (text,_,idx) => <b><img
        src={data[idx].icon}
        style={{width: 30, height: 30, marginRight: 6}}/> {text}</b>,
    },
    {
      title: '学科',
      dataIndex: 'subject',
      key: 'subject',
      render: (text) => <b style={{color: 'orange'}}>{text}</b>,
    },
    {
      title: '第四轮评估结果',
      dataIndex: 'level_4',
      key: 'level_4',
      render: text => <b style={{color: 'red', fontSize: 26}}>{text}</b>,
    },
  ];

  // 加载表格数据
  useEffect(() => {
    SubjectEvaluation({}).then(res => {
      if (res.status === 0) {
        setData(res.data)
        setLoading(false)
      }
    })
  }, [reload])

  return (
    <Table<any>
      rowKey={(record) => record.id}
      size="large"
      loading={loading}
      columns={columns}
      dataSource={data}
      className="TableParallel"
      pagination={{
        // style: { marginBottom: 0 },
        pageSize: 5,
        hideOnSinglePage: true,
        showSizeChanger: false,
        showQuickJumper: false
      }}
    />
  )
}

export default App;
